# Makefile for curses interface to Xconq.
# Copyright (C) 1991, 1992, 1993, 1994, 1995 Stanley T. Shebs.

# Xconq is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# Where cconq itself lives.

prefix = /usr/games

exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
datadir = $(prefix)/lib/xconq
mandir = $(prefix)/man
man6dir = $(mandir)/man6
infodir = $(prefix)/info
docdir = $(datadir)/doc

srcdir = .

krnsrcdir = $(srcdir)/../kernel

SHELL = /bin/sh

INSTALL = install -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)

CC = cc

CFLAGS = -g

CURSES_LIB = -lcurses -ltermlib

KERNEL_LIB = ../kernel/libconq.a

LOW_LIB = ../kernel/libconqlow.a

# Host and target-dependent makefile fragments come in here.
####
# End of host and target-dependent makefile fragments.

GAME_H = $(krnsrcdir)/game.h \
	 $(krnsrcdir)/gvar.def \
	 $(krnsrcdir)/utype.def \
	 $(krnsrcdir)/mtype.def \
	 $(krnsrcdir)/ttype.def \
	 $(krnsrcdir)/table.def

UNIT_H = $(krnsrcdir)/unit.h \
	 $(krnsrcdir)/action.def \
	 $(krnsrcdir)/plan.def \
	 $(krnsrcdir)/task.def

ALL_H = $(krnsrcdir)/conq.h \
	$(krnsrcdir)/config.h \
	$(krnsrcdir)/misc.h \
	$(krnsrcdir)/dir.h \
	$(krnsrcdir)/lisp.h \
	$(krnsrcdir)/module.h \
	$(GAME_H) \
	$(krnsrcdir)/player.h \
	$(krnsrcdir)/side.h \
	$(UNIT_H) \
	$(krnsrcdir)/goal.def \
	$(krnsrcdir)/world.h \
	$(krnsrcdir)/score.h \
	$(krnsrcdir)/history.h \
	$(krnsrcdir)/ai.h

C_H = $(srcdir)/cconq.h

OBJS = cconq.o cdraw.o ccmd.o

UNIX_CFLAGS = -DUNIX

# -Dcbreak=crmode

ALL_CFLAGS = $(CFLAGS) $(UNIX_CFLAGS) -I$(srcdir) -I$(krnsrcdir)

.c.o:
	$(CC) -c $(ALL_CFLAGS) $<

all:	cconq cconq.6

# The game itself.

cconq: $(OBJS) $(KERNEL_LIB) $(LOW_LIB)
	rm -f cconq
	$(CC) -o cconq $(ALL_CFLAGS) $(OBJS) $(KERNEL_LIB) $(LOW_LIB) $(CURSES_LIB)

$(KERNEL_LIB):
	(cd ../kernel; make libconq.a)

$(LOW_LIB):
	(cd ../kernel; make libconqlow.a)

# Man pages.

cconq.6:	cconq.6in ../kernel/cmdline.6in
	sed -e '/.so ...kernel.cmdline.6in/r $(srcdir)/../kernel/cmdline.6in' -e '/.so ...kernel.cmdline.6in/d' $(srcdir)/cconq.6in >cconq.6.new
	$(srcdir)/../move-if-change cconq.6.new cconq.6

# Installation.

install: all install-only

install-only:
	srcroot=`cd $(srcroot); pwd`; export srcroot; \
	$(INSTALL_PROGRAM) cconq $(bindir); \
	$(INSTALL_DATA) cconq.6 $(man6dir)

# Cleanliness support.

clean:
	rm -f *.o core
	rm -f cconq *.conq *.xconq

distclean: clean
	rm -f Makefile config.status

extraclean: distclean
	rm -f *~* .*~*

realclean: distclean

Makefile: Makefile.in $(host_makefile_frag) $(target_makefile_frag)
	$(SHELL) config.status

# Dependencies.

cconq.o:	$(ALL_H) $(C_H)
ccmd.o:		$(ALL_H) $(C_H)
cdraw.o:	$(ALL_H) $(C_H)
